package com.netty.study.handler;

import com.netty.study.dto.UserMessage;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;
import lombok.extern.slf4j.Slf4j;

@Slf4j
public class MessageServiceHandler extends SimpleChannelInboundHandler<UserMessage> {

    @Override
    protected void channelRead0(ChannelHandlerContext ctx, UserMessage msg) throws Exception {
        log.info("接收到参数数据：{}:{}", msg.getUserName(), msg.getMessage());
        UserMessage result = new UserMessage("服务器", "服务器接收到请求信息");
        ctx.writeAndFlush(result);
    }
}